#include <bits/stdc++.h>
using namespace std;
const int N=1e4+50;
const int M=2e6+50;
const int INF=1e9+50;
int n,m,a,b,s,t;
int val[N];
struct Edge{
    int v,w,next;
}edge[M];
int cnt,head[N];
void init(){
    cnt=0;
    memset(head,-1,sizeof(head));
}
void addEdge(int u,int v,int w){
    edge[cnt]=Edge{v,w,head[u]};
    head[u]=cnt++;
    edge[cnt]=Edge{u,0,head[v]};
    head[v]=cnt++;
}
int dep[N],cur[N];
bool bfs(){
    queue<int> q;
    memset(dep,0,sizeof(dep));
    dep[s]=1;
    q.push(s);
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=head[u];i!=-1;i=edge[i].next){
            int v=edge[i].v;
            int w=edge[i].w;
            if(w>0 && dep[v]==0){
                dep[v]=dep[u]+1;
                q.push(v);
            }
        }
    }
    return dep[t]!=0;
}
int dfs(int u,int flow){
    if(u==t){
        return flow;
    }
    for(int &i=cur[u];i!=-1;i=edge[i].next){
        int v=edge[i].v;
        int w=edge[i].w;
        if(dep[v]==dep[u]+1 && w!=0){
            int dis=dfs(v,min(w,flow));
            if(dis>0){
                edge[i].w-=dis;
                edge[i^1].w+=dis;
                return dis;
            }
        }
    }
    return 0;
}
int dinic(){
    int ans=0;
    while(bfs()){
		for(int i=0;i<=2*n+10;i++){
			cur[i]=head[i];
		}
        while(int d=dfs(s,INF)){
            ans+=d;
        }
    }
    return ans;
}
int main(void){
    //printf("%d\n",10000000*200);
    scanf("%d%d",&n,&m);
    scanf("%d%d",&a,&b);
    init();
    s=0;
    t=2*n+1;
    addEdge(s,a,INF);
    addEdge(b+n,t,INF);
    for(int i=1;i<=n;i++){
        scanf("%d",&val[i]);
        addEdge(i,i+n,val[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        addEdge(a+n,b,INF);
        addEdge(b+n,a,INF);
    }
    int ans=dinic();
    printf("%d\n",ans);
    return 0;
}